import Vue from 'vue'
import Router from 'vue-router'
import Layout from '../views/layout/Layout'

Vue.use(Router)

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/

export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  {
    path: '',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'dashboard',
        meta: { title: '首页', icon: 'dashboard' }
      }
    ]
  },
  {
    path: '/product',
    component: Layout,
    redirect: 'noredirect',
    meta: { title: '商品管理', icon: 'shoppingCard' },
    children: [
      {
        path: 'productList',
        component: () => import('@/views/product/productList'),
        name: 'productList',
        meta: { title: '商品列表', icon: '' }
      },
      {
        path: 'productEdit',
        component: () => import('@/views/product/productEdit'),
        name: 'productEdit',
        hidden: true,
        meta: { title: '商品编辑', icon: '' }
      },
      {
        path: 'productFrontCategory',
        component: () => import('@/views/product/productFrontCategory'),
        name: 'productFrontCategory',
        meta: { title: '商品前台分类', icon: '' }
      },
      {
        path: 'productBackCategory',
        component: () => import('@/views/product/productBackCategory'),
        name: 'productBackCategory',
        meta: { title: '商品后台分类', icon: '' }
      },
      {
        path: 'productCategorySort',
        component: () => import('@/views/product/productCategorySort'),
        name: 'productCategorySort',
        meta: { title: '商品分类排序', icon: '' }
      }
      // {
      //   path: 'productSort',
      //   component: () => import('@/views/product/productSort'),
      //   name: 'productSort',
      //   meta: { title: '商品排序', icon: '' }
      // }
    ]
  },
  {
    path: '/order',
    component: Layout,
    redirect: 'noredirect',
    meta: { title: '订单管理', icon: 'chart' },
    children: [
      {
        path: 'orderList',
        component: () => import('@/views/order/orderList'),
        name: 'orderList',
        meta: { title: '订单列表' }
      },
      {
        path: 'afterSaleOrderList',
        component: () => import('@/views/order/afterSaleOrderList'),
        name: 'afterSaleOrderList',
        meta: { title: '售后订单' }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    redirect: 'noredirect',
    meta: { title: '用户管理', icon: 'peoples' },
    children: [
      {
        path: 'userGradeOperation',
        component: () => import('@/views/user/userGradeOperation'),
        name: 'userGradeOperation',
        meta: { title: '用户等级管理' }
      }, {
        path: 'userMegOperation',
        component: () => import('@/views/user/userMegOperation'),
        name: 'userMegOperation',
        meta: { title: '用户信息管理' }
      }, {
        path: 'userWithdrawals',
        component: () => import('@/views/user/userWithdrawals'),
        name: 'userWithdrawals',
        meta: { title: '用户提现' }
      },
      {
        path: 'feedback',
        component: () => import('@/views/user/feedback'),
        name: 'feedback',
        meta: { title: '问题反馈' }
      }
    ]
  },
  {
    path: '/operation',
    component: Layout,
    redirect: 'noredirect',
    meta: { title: '运营管理', icon: 'international' },
    children: [
      {
        path: 'screenAdList',
        component: () => import('@/views/operation/screenAdList'),
        name: 'screenAdList',
        meta: { title: '闪屏广告' }
      },
      {
        path: 'adList',
        component: () => import('@/views/operation/adList'),
        name: 'adList',
        meta: { title: 'banner列表' }
      },
      {
        path: 'categoryAdList',
        component: () => import('@/views/operation/categoryAdList'),
        name: 'categoryAdList',
        meta: { title: '运营分类' }
      },
      {
        path: 'qyOptimization',
        component: () => import('@/views/operation/qyOptimization'),
        name: 'qyOptimization',
        meta: { title: '品质优选' }
      },
      {
        path: 'goodOperation',
        component: () => import('@/views/operation/goodOperation'),
        name: 'goodOperation',
        hidden: true,
        meta: { title: '运营分类' }
      },
      {
        path: 'goodOperations',
        component: () => import('@/views/operation/goodOperations'),
        name: 'goodOperations',
        hidden: true,
        meta: { title: '限时特价' }
      },
      {
        path: 'timeLimitList',
        component: () => import('@/views/operation/timeLimitList'),
        name: 'timeLimitList',
        meta: { title: '限时特价' }
      }
      // {
      //   path: 'qualityProductList',
      //   component: () => import('@/views/operation/qualityProductList'),
      //   name: 'qualityProductList',
      //   meta: { title: '品质优选' }
      // }
    ]
  },
  {
    path: '/system',
    component: Layout,
    redirect: 'noredirect',
    meta: { title: '系统管理', icon: 'documentation' },
    children: [
      {
        path: 'freightTemplate',
        component: () => import('@/views/system/freightTemplate'),
        name: 'freightTemplate',
        meta: { title: '运费模板' }
      },
      {
        path: 'versionManage',
        component: () => import('@/views/system/versionManage'),
        name: 'versionManage',
        meta: { title: '版本管理' }
      }
      // {
      //   path: 'operationLog',
      //   component: () => import('@/views/system/operationLog'),
      //   name: 'operationLog',
      //   meta: { title: '操作日志' }
      // }
    ]
  },
  {
    path: '/account',
    component: Layout,
    redirect: 'noredirect',
    meta: { title: '账号管理', icon: 'password' },
    children: [
      {
        path: 'accountManage',
        component: () => import('@/views/account/accountManage'),
        name: 'accountManage',
        meta: { title: '账号管理', icon: 'password' }
      }
    ]
  }
]

export default new Router({
  // mode: 'history', // 后端支持可开
  base: process.env.VUE_APP_BASE_URL,
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
